logger_config = {
  "version": 1,
  "disable_existing_loggers": False,

  # 日志格式定义
  "formatters": {
    # 标准格式：包含时间、日志级别、模块名等基本信息
    "standard": {
      # "format": "%(asctime)s - %(levelname)s - %(name)s - %(module)s - %(funcName)s - %(thread)d - %(threadName)s - %(process)d - %(message)s",
      "format": "%(asctime)s - %(levelname)s - %(name)s - %(module)s - %(funcName)s - %(message)s",
      "datefmt": "%Y-%m-%d %H:%M:%S"
    },
    # 简单格式：只包含时间、级别和消息
    "simple": {
      "format": "%(asctime)s - %(levelname)s - %(message)s",
      "datefmt": "%Y-%m-%d %H:%M:%S"
    },
    # 错误格式：包含更多上下文信息，用于错误日志
    "error": {
      "format": "%(asctime)s - %(levelname)s - %(name)s - %(module)s - %(funcName)s\n  Path: %(pathname)s:%(lineno)d\n  Process: [%(process)d:%(processName)s]\n  Thread: [%(thread)d:%(threadName)s]\n  Message: %(message)s\n",
      "datefmt": "%Y-%m-%d %H:%M:%S"
    }
  },

  # 处理器定义
  "handlers": {
    # 添加控制台处理器
    "console": {
      "class": "logging.StreamHandler",
      "level": "INFO",
      "formatter": "standard",
      "stream": "ext://sys.stdout"
    },
    # INFO级别日志文件处理器
    "info_file": {
      "class": "logging.handlers.RotatingFileHandler",
      "level": "INFO",
      "formatter": "standard",
      "filename": "logs/info.log",
      "maxBytes": 10485760,
      "backupCount": 5,
      "encoding": "utf-8"
    },
    # WARNING级别日志文件处理器
    "warning_file": {
      "class": "logging.handlers.RotatingFileHandler",
      "level": "WARNING",
      "formatter": "standard",
      "filename": "logs/warning.log",
      "maxBytes": 10485760,
      "backupCount": 5,
      "encoding": "utf-8"
    },
    # ERROR级别日志文件处理器
    "error_file": {
      "class": "logging.handlers.RotatingFileHandler",
      "level": "ERROR",
      "formatter": "error",
      "filename": "logs/error.log",
      "maxBytes": 10485760,
      "backupCount": 5,
      "encoding": "utf-8"
    }
  },

  # 日志器定义
  "loggers": {
    # 根日志器配置
    "": {  # root logger
      "level": "INFO",
      "handlers": ["info_file", "warning_file", "error_file"],
      "propagate": False  # 根日志器不需要传播
    },
    # 请求日志器配置
    "request": {
      "level": "INFO",
      "handlers": ["info_file", "warning_file", "error_file"],
      "propagate": False  # 禁止向上传播，避免重复记录
    },
    "werkzeug": {  # werkzeug logger
      "level": "INFO",
      "handlers": ["console", "info_file", "warning_file", "error_file"],  # 确保 werkzeug 日志也输出到控制台
      "propagate": False
    },
    # Flask日志器配置
    "flask": {
      "level": "INFO",
      "handlers": ["console", "info_file", "warning_file", "error_file"],
      "propagate": False  # 禁止向上传播，避免重复记录
    }
  }
}
